﻿Imports System.IO

Namespace Maaharaa
    Public Class dvthesaurus

        Dim title As String = "Thesaurus"
        Dim tList As New Dictionary(Of String, String)
        Dim arr() As String
        Public suggestions() As String = Nothing
        Dim line As String
        Dim found As Boolean
        Dim thesPath As String = "Dictionaries/Thes_div.txt"

        Public Sub New(ByVal word As String)

            tList.Clear()
            found = False

            'search for the word...
            Try
                Dim sr As New StreamReader(thesPath)
                Do While sr.Peek() >= 0
                    line = sr.ReadLine
                    If line.StartsWith(word.ToLower & "|") Then
                        found = True
                        Exit Do
                    End If
                Loop
                sr.Dispose()
            Catch ex As Exception
                MsgBox(ex.ToString, MsgBoxStyle.Exclamation, title)
            End Try

            'load the suggestions into the listboxes...
            If found = True Then
                arr = line.Split("|")
                suggestions = arr(1).Split("،")
            Else
                Dim text As String = "ތިބަހާ ގުޅޭބަހެއް ނުފެނުނު"
                suggestions = text.Split(",")
            End If
        End Sub

        Public Function getsuggestion() As String()
            Return suggestions
        End Function

        Public Function isavailable() As Boolean
            Return found
        End Function


    End Class
End Namespace
